<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row :gutter="32" style="padding:16px 16px 0;margin-bottom:32px;">
        <el-card>
            <div slot="header" class="clearfix">
                <span>前十工序信息</span>
            </div>
            <el-table
                v-loading="loading"
                :data="workorderList"
                row-key="workorderId"
                default-expand-all
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                >
                <el-table-column label="名称" width="140" align="center" prop="deptName" />
                <el-table-column label="排序" width="140" align="center" prop="orderNum" />   
                <el-table-column prop="status" label="状态" width="100">
                  <template slot-scope="scope">
                   <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
                  </template>
                </el-table-column>    
                <el-table-column prop="status" label="工序图片" width="100">
                  <template slot-scope="scope">
                    <el-image class="imagePreview" :src="base_url+scope.row.email" :preview-src-list="[base_url+scope.row.email]">
                        <div slot="error" class="image-slot">
                            
                        </div>
                    </el-image>
                  </template>
                </el-table-column>       
                <el-table-column label="创建时间" width="220" align="center" prop="createTime" />
                <el-table-column label="更新时间" width="250px" align="center" prop="updateTime" :show-overflow-tooltip="true"/>
                <el-table-column label="创建人" width="" align="center" prop="createBy" :show-overflow-tooltip="true"/>
            </el-table>
        </el-card>
    </el-row>
    
    <el-row style="background:#fff;padding:16px 16px 0; margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
      </el-col>
    </el-row>

    
  </div>
</template>

<script>
import { proList } from "@/api/sop/manage";
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import RaddarChart from './dashboard/RaddarChart'
import PieChart from './dashboard/PieChart'
import BarChart from './dashboard/BarChart'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'Index',
  dicts: ['sys_normal_disable'],
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart
  },
  data() {
    return {
        loading: true,
        queryParams: {},
        workorderList: [],
        lineChartData: lineChartData.newVisitis,
        
        base_url: process.env.VUE_APP_BASE_API,
    }
  },
  created(){
      this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      proList(this.queryParams).then(response => {
        this.workorderList = response.data;
        this.loading = false;
      });
    },
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },
    // 点击工单编码    
    handleView(row){
      // this.$router.push({path: '/mes/pro/workorder', query: {id: row.id}})
      console.log(row)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
